/**
 * Author: luoqi
 * Created Date: 2025-11-13 01:08:17
 * Last Modified: 2025-11-15 00:22:18
 * Modified By: luoqi at <**@****>
 * Copyright (c) 2025 <*****>
 * Description:
 */

#include <bsp.h>
#include <cli.h>
#include <adc_port.h>
#include "dbg.h"

static int args_sample(int argc, char **argv)
{
    UNUSED(argc);
    UNUSED(argv);

    adc1_sampling_trigger();
    return 0;
}

static int args_read1(int argc, char **argv)
{
    UNUSED(argc);
    UNUSED(argv);

    QSH(" ADC1_CH2: %d\r\n", adc_read(ADC1_CH2));
    QSH(" ADC1_CH3: %d\r\n", adc_read(ADC1_CH3));
    QSH(" ADC1_CH4: %d\r\n", adc_read(ADC1_CH4));
    QSH(" ADC1_CH5: %d\r\n", adc_read(ADC1_CH5));
    QSH(" ADC1_CH6: %d\r\n", adc_read(ADC1_CH6));
    return 0;
}

static QCliArgsTable table[] = {
    {"s1", args_sample, "Sample ADC1"},
    {"read1", args_read1, "Read ADC1"},
};

static int cmd_adc_hdl(int argc, char **argv)
{
    if(argc == 1) {
        cli_help(table, sizeof(table));
        return 0;
    }
    CLI_ARGS_EXEC(argc, argv, table);
}

int cmd_adc_init(void)
{
    cli_add("adc", cmd_adc_hdl, "ADC command");
    return 0;
}
